package com.swpu.zdl.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.swpu.zdl.pojo.KeCheng;
import com.swpu.zdl.pojo.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface KeChengMapper extends BaseMapper<KeCheng> {
    @Select("SELECT * from kecheng k JOIN kecheng_xuanke kx on k.kno = kx.kno where cid = #{id}")
    public KeCheng getKeChengByid(Integer id);
    @Select("select * from kecheng")
    List<KeCheng> getAll();
    @Insert("insert into kecheng(kno, kname, kyuan_xi, kzhuan_ye, xue_shi, xue_fen)" +
            "values (#{kno},#{kname},#{kyuanXi},#{kzhuanYe},#{xueShi},#{xueFen})")
    Boolean addKeCheng(KeCheng keCheng);
    @Delete("delete from kecheng where kno = #{kno}")
    boolean deleteKeCheng(Integer kno);

    boolean updateKeCheng(@Param("kno") Integer kno,
                          @Param("kecheng") KeCheng keCheng);
    @Select("SELECT k.*,t.* from kecheng k JOIN kecheng_xuanke kx ON k.kno=kx.kno JOIN teacher t on \n" +
            "t.cid = kx.cid where k.kno = #{kno}")
    @ResultMap("KeChengMap")
    KeCheng getCoureseTeacher(String kno);
}
